//
//  MPlusLoginViewController.m
//  medicineplus
//
//  Created by gufei on 15-4-9.
//  Copyright (c) 2015年 chn_ruby@126.cn. All rights reserved.
//

#import "MPlusLoginViewController.h"
#import "MPlusLogin.h"
#import "MPlusString.h"
#import "DDLogMacros.h"

@interface MPlusLoginViewController ()

@end

@implementation MPlusLoginViewController
@synthesize mobileTextField;
@synthesize passwordTextField;

#pragma mark -
#pragma mark Lifecycle methods

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.mobileTextField.text = @"18917212395";
    self.passwordTextField.text =@"123456";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark -
#pragma mark implements BaseController
- (UIView *)aInitContentView {
    return self.view;
}

#pragma mark -
#pragma mark IBActions

- (IBAction)loginAction:(id)sender {
    NSString *username = self.mobileTextField.text;
    NSString *password = self.passwordTextField.text;
    if (username.length > 0 && password.length > 0) {
        [self showLoadingDialog];
        MPlusLogin *api = [[MPlusLogin alloc] initWithUsername:username password:password];
        [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
            DDLogInfo(@"succeed%@",request.responseString);
            [self hideLoadingDialog];
            [self showToast:@"登录成功"];
        } failure:^(YTKBaseRequest *request) {
            DDLogError(@"failed");
        }];
    } else {
        [self showToast:@"用户名或密码不能为空"];
    }
}


@end
